﻿using System;
using MyWeb.Business;
using MyWeb.Common;

namespace MyWeb.Modules.Products
{
    public partial class SlideProducts : System.Web.UI.Page
    {
        private string _id = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.RouteData.Values["proId"] != null) _id = Page.RouteData.Values["proId"].ToString();
            if(!IsPostBack)
            {
                ShowImage();
            }
        }
        private void ShowImage()
        {
            var s = "";
            var list = ImagesProductsService.ImagesProducts_GetByTop("", "Active = '1' and ProductsId = '"+ _id +"'", "");
            if(list.Count > 0)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    if(i == list.Count - 1)
                    {
                        s += "{image: '" + list[i].Images + "', title: '" + list[i].Name + "', thumb: '" + StringClass.ThumbImage(list[i].Images) + "', url: '" + list[i].Images + "' }\n";
                    }
                    else
                    {
                        s += "{image: '" + list[i].Images + "', title: '" + list[i].Name + "', thumb: '" + StringClass.ThumbImage(list[i].Images) + "', url: '" + list[i].Images + "' },\n";
                    }
                }
                ltrslide.Text = s;
            }
            #region html code
            /*
                {image: '/ImagesProduct/11.png', title: 'Tên hình ảnh 11', thumb: 'ImagesProduct/11.png', url: 'ImagesProduct/11.png' },
			    { image: '/ImagesProduct/22.png', title: 'Tên hình ảnh 22', thumb: 'ImagesProduct/22.png', url: 'ImagesProduct/22.png' },
                { image: '/ImagesProduct/33.png', title: 'Tên hình ảnh 33', thumb: 'ImagesProduct/33.png', url: 'ImagesProduct/33.png' },
                { image: '/ImagesProduct/44.png', title: 'Tên hình ảnh 44', thumb: 'ImagesProduct/44.png', url: 'ImagesProduct/44.png' }
             */
            #endregion
        }
    }
}